import http from 'service/util/http'

export default {
    // 银行集合
    all(data) {
        return http.post('/bank/all', data, ['userId']).then(res => {
            // 银行数据列表字段转换
            var { code, data } = res.data
            var newList = []
            var newLi
            if (code == 'S') {
                var { list } = data
                for (var i = 0; i < list.length; i++) {
                    var li = list[i]
                    newLi = {
                        value: li.bankCode,
                        text: li.bankName
                    }
                    newList.push(newLi)
                }
                data.list = newList
            }
            return res
        })
    },
    // 添加银行卡
    bind(data) {
        return http.post('/bank/bind', data, ['userId', 'bankCode', 'bankName', 'bankCard', 'bankMobile', 'provinceCode', 'provinceName', 'cityCode', 'cityName'])
    },
    // 银行卡信息
    cardInfo(data) {
        return http.post('/bank/card/info', data, ['userId'])
    }
}